<template>
  <h5>亚托莉·控制台</h5>
  <el-menu :default-active='nowactive'>
    <el-menu-item index="1" @click="goWelcome">
      <el-icon>
        <icon-menu />
      </el-icon>
      <span>欢迎</span>
    </el-menu-item>
    <el-sub-menu index="2">
      <template #title>
        <el-icon>
          <setting />
        </el-icon>

        <span>系统管理</span>
      </template>
      <el-menu-item-group>
        <el-menu-item index="2-1" @click="router.push('/home/plug')">插件管理</el-menu-item>
        <el-menu-item index="2-2" @click="router.push('/home/dict')">词库管理</el-menu-item>
        <el-menu-item index="2-3" @click="router.push('/home/password')">密码修改</el-menu-item>
      </el-menu-item-group>
    </el-sub-menu>

    <el-menu-item index="3" @click="goAbout">
      <el-icon>
        <document />
      </el-icon>
      <span>关于</span>
    </el-menu-item>
  </el-menu>
  <div class="bottom">
    <el-button type="danger" plain round @click="quit">
      <el-icon>
        <lock />
      </el-icon>退出登录
    </el-button>
  </div>
</template>
<script setup>
import {
  Location,
  Document,
  Menu as IconMenu,
  Setting,
  Lock
} from '@element-plus/icons-vue'
import { useRouter,useRoute } from 'vue-router'
import {setCookie,delCookie}from '../utils/cookies.js'
const router = useRouter()
const path=useRoute().path
let nowactive='1'
if(path==='/home/about'){
  nowactive='3'
}
else if(path==='/home/plug'){
  nowactive='2-1'
}
else if(path==='/home/dict'){
  nowactive='2-2'
}
else if(path==='/home/password'){
  nowactive='2-3'
}
function quit() {
  delCookie('token')
  router.push('/login')
}
function goWelcome() {
  router.push('/home/welcome')
}
function goAbout(){
  router.push('/home/about')
}
</script>

<style scoped> 
h5 {
  margin: 7% 10%;
  text-align: center;
  font-size: 25px;
  border-style: solid;
  border-radius: 18px;
  font-style: normal;
  font-family: 宋体;
}
.el-menu-item-group__title {
  padding: 0px;
}
.bottom {
  position: absolute;
  width: 100%;
  bottom: 0px;
  padding-bottom: 35px;
  text-align: center;
}
</style>
